/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.merak.core.persistence.jdbc.settings;

import org.merak.core.model.Identifiable;

public enum SettingType implements Identifiable<Integer> {

	//~ Attributes ///////////////////////////////////////////////////////////////
	//****************************************************************************
	UNKNOWN(-1),
	FORM(0),
	URL(1),
	DATA_SOURCE(2);

    //~ Attributes ///////////////////////////////////////////////////////////////
    //****************************************************************************
	private final Integer id;

    //~ Constructors /////////////////////////////////////////////////////////////
    //****************************************************************************
	private SettingType(int id) {
		this.id = id;
	}

	//~ Methods //////////////////////////////////////////////////////////////////
	//****************************************************************************
	@Override
	public Integer getId() {
		return this.id;
	}
	//****************************************************************************
	@Override
	public boolean hasId(Integer id) {
		return this.id.equals(id);
	}
	//****************************************************************************
	@Override
	public boolean anonymous() {
		return false;
	}
	//****************************************************************************
	@Override
	public boolean selfsame(Identifiable<Integer> obj) {
		return obj == this;
	}
	//****************************************************************************
	public boolean isUnknown() {
		return this == UNKNOWN;
	}
    //****************************************************************************
	public static SettingType parse(String name) {

		for (SettingType e : values()) {
			if ( e.name().equalsIgnoreCase(name) ) return e;
		}
		return SettingType.UNKNOWN;

	}
    //****************************************************************************
	public static SettingType getValue(int id) {

		for (SettingType e : values()) {
			if ( e.hasId(id) ) return e;
		}
		return SettingType.UNKNOWN;

	}
	//****************************************************************************
}

